﻿using Steamworks;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;

[RequireComponent(typeof(NetworkManager))]
public class SteamNetworkManager : MonoBehaviour
{
    [CompilerGenerated]
    private static Action <>f__am$cache10;
    [CompilerGenerated]
    private static Action <>f__am$cache11;
    [CompilerGenerated]
    private static Action <>f__am$cache12;
    [CompilerGenerated]
    private static Callback<P2PSessionRequest_t>.DispatchDelegate <>f__am$cache13;
    [CompilerGenerated]
    private static Callback<P2PSessionConnectFail_t>.DispatchDelegate <>f__am$cache14;
    [CompilerGenerated]
    private static Callback<SocketStatusCallback_t>.DispatchDelegate <>f__am$cache15;
    [CompilerGenerated]
    private static Callback<LobbyChatMsg_t>.DispatchDelegate <>f__am$cache16;
    [CompilerGenerated]
    private static Callback<LobbyDataUpdate_t>.DispatchDelegate <>f__am$cache17;
    private bool applicationQuitted;
    public static List<string> chatLogs = new List<string>();
    private static CSteamID currentLobby;
    private string inputtedLobbyName = string.Empty;
    private static SteamNetworkManager Instance;
    private bool isCreatingLobby;
    private bool isJoining;
    private bool isRefreshingLobby;
    private const string key_host = "host";
    private uint lobbyCount;
    [SerializeField]
    private bool m_isDebugging;
    [SerializeField]
    private GameObject m_ui;
    private NetworkManager manager;
    public static int maxChatLogCount = 10;
    private Vector2 pos;
    private CSteamID selectedLobby = CSteamID.Nil;

    public static  event Action onChatLogsChanged;

    static SteamNetworkManager()
    {
        if (<>f__am$cache10 == null)
        {
            <>f__am$cache10 = new Action(SteamNetworkManager.<onChatLogsChanged>m__107);
        }
        onChatLogsChanged = <>f__am$cache10;
        if (<>f__am$cache11 == null)
        {
            <>f__am$cache11 = new Action(SteamNetworkManager.<SteamNetworkManager>m__108);
        }
        ReadyRoomScene.onLoaded += <>f__am$cache11;
        if (<>f__am$cache12 == null)
        {
            <>f__am$cache12 = new Action(SteamNetworkManager.<SteamNetworkManager>m__109);
        }
        ReadyRoomScene.onStartGame += <>f__am$cache12;
    }

    [CompilerGenerated]
    private static void <onChatLogsChanged>m__107()
    {
    }

    [CompilerGenerated]
    private static void <SteamNetworkManager>m__108()
    {
        SetIsLobbyIngame(currentLobby, false);
    }

    [CompilerGenerated]
    private static void <SteamNetworkManager>m__109()
    {
        SetIsLobbyIngame(currentLobby, true);
    }

    private void Awake()
    {
        Instance = this;
        this.manager = base.GetComponent<NetworkManager>();
    }

    private void ConnectClientToServer(CSteamID remoteId)
    {
        if (isDebugging)
        {
            UnityEngine.Debug.Log("ConnectClientToServer");
        }
        NetworkManager singleton = NetworkManager.singleton;
        SteamNetworkConnection conn = this.CreateConnection(remoteId);
        NetworkClient externalClient = new NetworkClient(conn);
        singleton.UseExternalClient(externalClient);
        if (isDebugging)
        {
            UnityEngine.Debug.Log("InvokeHandlerNoData: Connect");
        }
        conn.InvokeHandlerNoData(0x20);
    }

    private void ConnectServerToClient(CSteamID remoteId)
    {
        if (IsLobbyIngame(currentLobby))
        {
            if (isDebugging)
            {
                UnityEngine.Debug.Log("Rejected client connection, ingame is started");
            }
        }
        else
        {
            if (isDebugging)
            {
                UnityEngine.Debug.Log("ConnectServerToClient");
            }
            SteamNetworkConnection conn = this.CreateConnection(remoteId);
            this.Send(remoteId, 0x20, null);
            NetworkServer.AddExternalConnection(conn);
            NetworkServer.dontListen = true;
        }
    }

    private SteamNetworkConnection CreateConnection(CSteamID remoteId)
    {
        if (isDebugging)
        {
            UnityEngine.Debug.Log(string.Format("CreateConnection: from {0} to {1}", selfId, remoteId));
        }
        SteamMatchmaking.SetLobbyMemberData(currentLobby, "isConnected", "true");
        NetworkManager singleton = NetworkManager.singleton;
        SteamNetworkConnection connection = new SteamNetworkConnection {
            selfId = selfId,
            remoteId = remoteId
        };
        ConnectionConfig defaultConfig = new ConnectionConfig();
        foreach (QosType type in GameNetworkChannels.allChannels)
        {
            defaultConfig.AddChannel(type);
        }
        try
        {
            HostTopology hostTopology = new HostTopology(defaultConfig, this.maxConnections);
            int count = NetworkServer.connections.Count;
            connection.Initialize(null, -1, count, hostTopology);
            singleton.maxDelay = 0f;
            connection.SetMaxDelay(singleton.maxDelay);
        }
        catch (Exception exception)
        {
            UnityEngine.Debug.LogException(exception);
        }
        SetIsConnected(selfId, true);
        return connection;
    }

    private void CreateLobby()
    {
        this.isCreatingLobby = true;
        if (string.IsNullOrEmpty(this.inputtedLobbyName))
        {
            this.inputtedLobbyName = SteamFriends.GetPersonaName() + "'s Lobby";
        }
        SteamMatchmaking.CreateLobby(ELobbyType.k_ELobbyTypePublic, this.maxConnections).CreateCallResult<LobbyCreated_t>(delegate (LobbyCreated_t c, bool f) {
            CSteamID steamIDLobby = new CSteamID(c.m_ulSteamIDLobby);
            SteamMatchmaking.SetLobbyData(steamIDLobby, "name", this.inputtedLobbyName);
            SteamMatchmaking.SetLobbyData(steamIDLobby, "host", selfId.ToString());
            if (isDebugging)
            {
                UnityEngine.Debug.Log(string.Format("CreateLobby: {0} id:{1}", c.m_eResult, c.m_ulSteamIDLobby));
            }
            this.JoinLobby(steamIDLobby, delegate {
                this.isCreatingLobby = false;
                this.StartHost();
            });
        });
        if (isDebugging)
        {
            UnityEngine.Debug.Log("CreateLobby");
        }
    }

    private void DisconnectClientOnServer(CSteamID remoteId)
    {
        SteamNetworkConnection connection = this.FindConnectionOnServer(remoteId);
        NetworkServer.RemoveExternalConnection(connection.connectionId);
        connection.InvokeHandlerNoData(0x21);
    }

    private SteamNetworkConnection FindConnectionOnServer(CSteamID remoteId)
    {
        for (int i = 0; i < NetworkServer.connections.Count; i++)
        {
            SteamNetworkConnection connection = NetworkServer.connections[i] as SteamNetworkConnection;
            if ((connection != null) && (connection.remoteId == remoteId))
            {
                return connection;
            }
        }
        return null;
    }

    private void InitUI()
    {
        <InitUI>c__AnonStorey6F storeyf = new <InitUI>c__AnonStorey6F {
            <>f__this = this
        };
        this.m_ui.SetActive(true);
        this.RefreshLobbyListUI();
        this.StartWaitForSeconds(1f, new Action(storeyf.<>m__114));
        Transform transform = this.m_ui.FindChild("Buttons");
        storeyf.joinButton = transform.FindChild<Button>("JoinLobby");
        storeyf.joinButton.SetListener(new UnityAction(storeyf.<>m__115));
        transform.FindChild<Button>("RefreshList").SetListener(new UnityAction(storeyf.<>m__116));
        transform.FindChild<Button>("CreateLobby").SetListener(new UnityAction(storeyf.<>m__117));
        storeyf.processing = this.m_ui.FindChild("Processing");
        this.StartUpdate(new Action(storeyf.<>m__118));
    }

    private static bool IsConnected(CSteamID memberId)
    {
        return ((SteamMatchmaking.GetLobbyOwner(currentLobby) == memberId) || (SteamMatchmaking.GetLobbyMemberData(currentLobby, memberId, "isConnected") == "true"));
    }

    private static bool IsLobbyIngame(CSteamID lobby)
    {
        return (SteamMatchmaking.GetLobbyData(lobby, "isIngame") == "true");
    }

    private void JoinLobby(CSteamID lobby, Action onJoined = null)
    {
        <JoinLobby>c__AnonStorey6E storeye = new <JoinLobby>c__AnonStorey6E {
            onJoined = onJoined,
            <>f__this = this
        };
        if (lobby.IsValid())
        {
            this.isJoining = true;
            SteamMatchmaking.JoinLobby(lobby).CreateCallResult<LobbyEnter_t>(new Action<LobbyEnter_t, bool>(storeye.<>m__112));
            if (isDebugging)
            {
                UnityEngine.Debug.Log("JoinLobby " + lobby);
            }
        }
    }

    private void JoinLobbyAndConnectToServer(CSteamID lobby)
    {
        <JoinLobbyAndConnectToServer>c__AnonStorey6D storeyd = new <JoinLobbyAndConnectToServer>c__AnonStorey6D {
            lobby = lobby,
            <>f__this = this
        };
        if (IsLobbyIngame(storeyd.lobby))
        {
            this.RefreshLobbyList();
        }
        else
        {
            this.JoinLobby(storeyd.lobby, new Action(storeyd.<>m__110));
        }
    }

    private void LeaveLobby()
    {
        if (isDebugging)
        {
            MonoBehaviour.print("LeaveLobby");
        }
        SteamMatchmaking.LeaveLobby(currentLobby);
        if (NetworkServer.active)
        {
            SteamMatchmaking.SetLobbyData(currentLobby, "host", string.Empty);
            this.manager.StopHost();
        }
        else if (NetworkClient.active)
        {
            this.manager.StopClient();
        }
        this.lobbyCount = 0;
        this.StartWaitForSeconds(1f, new Action(this.RefreshLobbyList));
        currentLobby = CSteamID.Nil;
    }

    private void OnApplicationQuit()
    {
        this.applicationQuitted = true;
    }

    private void OnClientMemberLeft(CSteamID member)
    {
        if (isDebugging)
        {
            UnityEngine.Debug.Log("Member left:" + member);
        }
        this.DisconnectClientOnServer(member);
    }

    private void OnDestroy()
    {
        if (!this.applicationQuitted)
        {
            this.LeaveLobby();
        }
    }

    private void OnDisable()
    {
        SteamEventManager.ClearListeners(this);
    }

    private void OnEnable()
    {
        if (<>f__am$cache13 == null)
        {
            <>f__am$cache13 = delegate (P2PSessionRequest_t v) {
                UnityEngine.Debug.Log("P2PSessionRequest_t " + v.m_steamIDRemote);
                SteamNetworking.AcceptP2PSessionWithUser(v.m_steamIDRemote);
            };
        }
        SteamEventManager.RegisterListener<P2PSessionRequest_t>(this, <>f__am$cache13);
        if (<>f__am$cache14 == null)
        {
            <>f__am$cache14 = v => UnityEngine.Debug.Log("P2PSessionConnectFail_t " + v.m_eP2PSessionError);
        }
        SteamEventManager.RegisterListener<P2PSessionConnectFail_t>(this, <>f__am$cache14);
        if (<>f__am$cache15 == null)
        {
            <>f__am$cache15 = v => UnityEngine.Debug.Log("SocketStatusCallback_t " + v.m_steamIDRemote);
        }
        SteamEventManager.RegisterListener<SocketStatusCallback_t>(this, <>f__am$cache15);
        if (<>f__am$cache16 == null)
        {
            <>f__am$cache16 = delegate (LobbyChatMsg_t v) {
                CSteamID mid;
                EChatEntryType type;
                byte[] pvData = new byte[0x1000];
                int count = SteamMatchmaking.GetLobbyChatEntry(currentLobby, (int) v.m_iChatID, out mid, pvData, pvData.Length, out type);
                string item = Encoding.UTF8.GetString(pvData, 0, count);
                if (isDebugging)
                {
                    UnityEngine.Debug.Log("GetLobbyChatEntry : " + count);
                }
                chatLogs.Add(item);
                if (chatLogs.Count > maxChatLogCount)
                {
                    chatLogs.RemoveAt(0);
                }
                onChatLogsChanged();
            };
        }
        SteamEventManager.RegisterListener<LobbyChatMsg_t>(this, <>f__am$cache16);
        if (<>f__am$cache17 == null)
        {
            <>f__am$cache17 = delegate (LobbyDataUpdate_t v) {
            };
        }
        SteamEventManager.RegisterListener<LobbyDataUpdate_t>(this, <>f__am$cache17);
        SteamEventManager.RegisterListener<LobbyChatUpdate_t>(this, delegate (LobbyChatUpdate_t v) {
            if (isDebugging)
            {
                object[] args = new object[] { (EChatMemberStateChange) v.m_rgfChatMemberStateChange, v.m_ulSteamIDLobby, v.m_ulSteamIDMakingChange, v.m_ulSteamIDUserChanged };
                UnityEngine.Debug.Log(string.Format("OnLobbyChatUpdate : {0},{1},{2},{3}", args));
            }
            EChatMemberStateChange rgfChatMemberStateChange = (EChatMemberStateChange) v.m_rgfChatMemberStateChange;
            CSteamID steamIDLobby = (CSteamID) v.m_ulSteamIDLobby;
            CSteamID member = (CSteamID) v.m_ulSteamIDUserChanged;
            switch (rgfChatMemberStateChange)
            {
                case EChatMemberStateChange.k_EChatMemberStateChangeEntered:
                    this.OnMemberJoined(member);
                    break;

                case EChatMemberStateChange.k_EChatMemberStateChangeLeft:
                    if (member.ToString() == SteamMatchmaking.GetLobbyData(steamIDLobby, "host"))
                    {
                        this.OnHostMemberLeft(member);
                    }
                    else
                    {
                        this.OnClientMemberLeft(member);
                    }
                    break;
            }
        });
    }

    private void OnHostMemberLeft(CSteamID member)
    {
        if (isDebugging)
        {
            UnityEngine.Debug.Log("OnHostMemberLeft:" + member);
        }
        this.LeaveLobby();
    }

    private void OnMemberJoined(CSteamID member)
    {
        if (isDebugging)
        {
            UnityEngine.Debug.Log("Member joined:" + member);
        }
    }

    private void Read(int channel)
    {
        uint num;
        if (SteamNetworking.IsP2PPacketAvailable(out num, channel))
        {
            uint num2;
            CSteamID mid;
            byte[] pubDest = new byte[num];
            if (SteamNetworking.ReadP2PPacket(pubDest, num, out num2, out mid, channel))
            {
                if (isDebugging)
                {
                    object[] args = new object[] { num, num2, mid, channel };
                    MonoBehaviour.print(string.Format("ReadP2PPacket MsgSize:{0} newMsgSize:{1} senderId:{2} channel:{3} ", args));
                }
                SteamNetworkConnection connection = null;
                if (NetworkServer.active)
                {
                    connection = this.FindConnectionOnServer(mid);
                }
                else
                {
                    connection = (NetworkManager.singleton.client == null) ? null : (NetworkManager.singleton.client.connection as SteamNetworkConnection);
                }
                if (connection == null)
                {
                    NetworkReader reader = new NetworkReader(pubDest);
                    reader.ReadUInt16();
                    short num3 = reader.ReadInt16();
                    if (isDebugging)
                    {
                        UnityEngine.Debug.Log("message before connection created: " + num3);
                    }
                    if (NetworkServer.active)
                    {
                        if (num3 == 0x20)
                        {
                            this.ConnectServerToClient(mid);
                        }
                    }
                    else if (num3 == 0x20)
                    {
                        this.ConnectClientToServer(mid);
                    }
                }
                if (connection != null)
                {
                    connection.TransportRecieve(pubDest, (int) num2, channel);
                }
            }
        }
    }

    private void RefreshLobbyList()
    {
        this.isRefreshingLobby = true;
        SteamMatchmaking.RequestLobbyList().CreateCallResult<LobbyMatchList_t>(delegate (LobbyMatchList_t c, bool f) {
            this.lobbyCount = c.m_nLobbiesMatching;
            this.isRefreshingLobby = false;
            if (isDebugging)
            {
                MonoBehaviour.print("lobbyCount :" + this.lobbyCount);
            }
            this.RefreshLobbyListUI();
        });
        if (isDebugging)
        {
            MonoBehaviour.print("RequestLobbyList");
        }
    }

    private void RefreshLobbyListUI()
    {
        this.selectedLobby = CSteamID.Nil;
        Transform transform = this.m_ui.FindChild("LobbyList/Scroll View/Viewport/Contents");
        Transform parent = this.m_ui.FindChild("LobbyList/Header");
        Toggle comp = transform.FindChild<Toggle>("Content");
        if (parent.childCount == 0)
        {
            Toggle toggle2 = comp.CloneGameObjectAsChild<Toggle>(parent, true);
            UnityEngine.Object.Destroy(toggle2.GetComponent<Image>());
            UnityEngine.Object.Destroy(toggle2.GetComponent<Toggle>());
        }
        UIUtility.RefreshElements<Toggle>(comp, (int) this.lobbyCount, transform, delegate (Toggle c, int i) {
            <RefreshLobbyListUI>c__AnonStorey70 storey = new <RefreshLobbyListUI>c__AnonStorey70 {
                <>f__this = this,
                lobby = SteamMatchmaking.GetLobbyByIndex(i)
            };
            string lobbyData = SteamMatchmaking.GetLobbyData(storey.lobby, "name");
            int numLobbyMembers = SteamMatchmaking.GetNumLobbyMembers(SteamMatchmaking.GetLobbyByIndex(i));
            c.onValueChanged.SetListener(new UnityAction<bool>(storey.<>m__11B));
            c.isOn = false;
            c.FindChild<Text>("ID").text = i + string.Empty;
            c.FindChild<Text>("Name").text = lobbyData;
            c.FindChild<Text>("Members").text = string.Format("{0}/{1}", numLobbyMembers, this.maxConnections);
            c.FindChild<Text>("Status").text = !IsLobbyIngame(storey.lobby) ? "Waiting" : "<color=#660000>Ingame</color>";
        });
    }

    private void RemoveClient()
    {
    }

    private void Send(CSteamID remoteId, short msgType, MessageBase msg = null)
    {
        NetworkWriter writer = new NetworkWriter();
        writer.StartMessage(msgType);
        if (msg != null)
        {
            writer.Write(msg);
        }
        writer.FinishMessage();
        byte[] pubData = writer.AsArray();
        if (isDebugging)
        {
            MonoBehaviour.print(string.Format("SendP2PPacket MsgSize:{0} msgType:{1}", pubData.Length, msgType));
        }
        SteamNetworking.SendP2PPacket(remoteId, pubData, (uint) pubData.Length, EP2PSend.k_EP2PSendReliable, 0);
    }

    public static void SendChatMsg(string text)
    {
        byte[] bytes = Encoding.UTF8.GetBytes(text);
        bool flag = SteamMatchmaking.SendLobbyChatMsg(currentLobby, bytes, bytes.Length);
        if (isDebugging)
        {
            UnityEngine.Debug.Log(string.Format("Send {0} : {1} , lobby:{2}", text, flag, currentLobby));
        }
    }

    private void SendConnectRequestClientToServer(CSteamID remoteId)
    {
        if (isDebugging)
        {
            MonoBehaviour.print(string.Format("SendConnectRequestClientToServer", new object[0]));
        }
        this.Send(remoteId, 0x20, null);
    }

    private static void SetIsConnected(CSteamID memberId, bool value)
    {
        SteamMatchmaking.SetLobbyMemberData(memberId, "isConnected", value.ToString());
    }

    private static void SetIsLobbyIngame(CSteamID lobby, bool value)
    {
        if (Instance != null)
        {
            if (isDebugging)
            {
                object[] args = new object[] { lobby, value };
                UnityEngine.Debug.LogFormat("SetIsLobbyIngame '{0}' = {1}", args);
            }
            SteamMatchmaking.SetLobbyData(lobby, "isIngame", !value ? string.Empty : "true");
        }
    }

    [DebuggerHidden]
    private IEnumerator Start()
    {
        return new <Start>c__Iterator10 { <>f__this = this };
    }

    private void StartHost()
    {
        if (isDebugging)
        {
            MonoBehaviour.print("StartHost");
        }
        NetworkServer.Reset();
        NetworkManager.singleton.StartHost();
    }

    private void Update()
    {
        if (SteamManager.Initialized)
        {
            for (int i = 0; i < GameNetworkChannels.allChannels.Length; i++)
            {
                this.Read(i);
            }
        }
    }

    public static bool active
    {
        get
        {
            return (Instance != null);
        }
    }

    private bool isConnected
    {
        get
        {
            return IsConnected(selfId);
        }
    }

    private bool isConnecting
    {
        get
        {
            return (currentLobby.IsValid() && !this.isConnected);
        }
    }

    public static bool isDebugging
    {
        get
        {
            return ((Instance != null) && Instance.m_isDebugging);
        }
    }

    private bool isProcessing
    {
        get
        {
            return (((this.isRefreshingLobby || this.isCreatingLobby) || this.isJoining) || this.isConnecting);
        }
    }

    public bool isServer
    {
        get
        {
            return NetworkServer.active;
        }
    }

    private int maxConnections
    {
        get
        {
            return this.manager.maxConnections;
        }
    }

    private static CSteamID selfId
    {
        get
        {
            return SteamUser.GetSteamID();
        }
    }

    [CompilerGenerated]
    private sealed class <InitUI>c__AnonStorey6F
    {
        internal SteamNetworkManager <>f__this;
        internal Button joinButton;
        internal Transform processing;

        internal void <>m__114()
        {
            this.<>f__this.RefreshLobbyList();
        }

        internal void <>m__115()
        {
            this.<>f__this.JoinLobbyAndConnectToServer(this.<>f__this.selectedLobby);
        }

        internal void <>m__116()
        {
            this.<>f__this.RefreshLobbyList();
        }

        internal void <>m__117()
        {
            this.<>f__this.CreateLobby();
        }

        internal void <>m__118()
        {
            this.processing.SetActive(this.<>f__this.isProcessing);
            this.joinButton.gameObject.SetActive(this.<>f__this.selectedLobby.IsValid());
            if (this.<>f__this.isConnected)
            {
                this.<>f__this.m_ui.SetActive(false);
            }
        }
    }

    [CompilerGenerated]
    private sealed class <JoinLobby>c__AnonStorey6E
    {
        internal SteamNetworkManager <>f__this;
        internal Action onJoined;

        internal void <>m__112(LobbyEnter_t c, bool f)
        {
            this.<>f__this.isJoining = false;
            SteamNetworkManager.currentLobby = new CSteamID(c.m_ulSteamIDLobby);
            SteamMatchmaking.SetLobbyMemberData(SteamNetworkManager.currentLobby, "name", SteamFriends.GetPersonaName());
            if (SteamNetworkManager.isDebugging)
            {
                UnityEngine.Debug.Log(string.Format("Joined Lobby: {0}", c.m_ulSteamIDLobby));
            }
            if (this.onJoined != null)
            {
                this.onJoined();
            }
        }
    }

    [CompilerGenerated]
    private sealed class <JoinLobbyAndConnectToServer>c__AnonStorey6D
    {
        internal SteamNetworkManager <>f__this;
        internal CSteamID lobby;

        internal void <>m__110()
        {
            this.<>f__this.SendConnectRequestClientToServer(SteamMatchmaking.GetLobbyOwner(this.lobby));
            this.<>f__this.StartWaitForSeconds(5f, delegate {
                if (this.<>f__this.isConnecting)
                {
                    this.<>f__this.LeaveLobby();
                }
            });
        }

        internal void <>m__11D()
        {
            if (this.<>f__this.isConnecting)
            {
                this.<>f__this.LeaveLobby();
            }
        }
    }

    [CompilerGenerated]
    private sealed class <RefreshLobbyListUI>c__AnonStorey70
    {
        internal SteamNetworkManager <>f__this;
        internal CSteamID lobby;

        internal void <>m__11B(bool v)
        {
            if (v)
            {
                this.<>f__this.selectedLobby = this.lobby;
            }
        }
    }

    [CompilerGenerated]
    private sealed class <Start>c__Iterator10 : IDisposable, IEnumerator, IEnumerator<object>
    {
        internal object $current;
        internal int $PC;
        private static Func<bool> <>f__am$cache3;
        internal SteamNetworkManager <>f__this;

        private static bool <>m__11C()
        {
            return SteamManager.Initialized;
        }

        [DebuggerHidden]
        public void Dispose()
        {
            this.$PC = -1;
        }

        public bool MoveNext()
        {
            uint num = (uint) this.$PC;
            this.$PC = -1;
            switch (num)
            {
                case 0:
                    if (<>f__am$cache3 == null)
                    {
                        <>f__am$cache3 = new Func<bool>(SteamNetworkManager.<Start>c__Iterator10.<>m__11C);
                    }
                    this.$current = new WaitUntil(<>f__am$cache3);
                    this.$PC = 1;
                    return true;

                case 1:
                    this.<>f__this.InitUI();
                    Player.customPlayerName = SteamFriends.GetPersonaName();
                    this.$PC = -1;
                    break;
            }
            return false;
        }

        [DebuggerHidden]
        public void Reset()
        {
            throw new NotSupportedException();
        }

        object IEnumerator<object>.Current
        {
            [DebuggerHidden]
            get
            {
                return this.$current;
            }
        }

        object IEnumerator.Current
        {
            [DebuggerHidden]
            get
            {
                return this.$current;
            }
        }
    }
}

